<template>
    <div>
        <h1>学生管理系统</h1>
        <p>用户名：<input type="text" v-model="name"></p>
        <p>密 码：<input type="text" v-model="password"></p>
        <button @click="login">登录</button>
    </div>
</template>

<script>

import axios from 'axios'
export default {
    data() {
        return {
            name:'',
            password:'',
            bath_url:'http://127.0.0.1:8000'
        }
    },
    methods: {
        login(){
            console.log(this.name,this.password)
            let form_data = new FormData();
            form_data.append('name',this.name)
            form_data.append('password',this.password)
            axios({
                url:this.bath_url + '/app01/login',
                method:'post',
                data:form_data
            }).then(res =>{
                localStorage.setItem('key',res.data.data)
                console.log(res.data)
                alert(res.data.msg)
                this.$router.push({
                    name:'/'
                })
                
            })
        }
    },
    created() {

    }
}
</script>

<style>
table{
    width: 500px;
    /* height: 500px;  */
    border: solid black;
    margin: 0 auto;
    border-collapse:collapse
}
th,td{
    border: green solid;
    border-collapse:collapse
}
a{
    padding: 5px 10px;
    border: 1px solid lightblue;
    margin-right: 10px;
    cursor: pointer;
}
</style>